#pragma once

#include "stdio.h"
#include "stdlib.h"

typedef int ElemType;

typedef struct Node {
    ElemType data;
    struct Node* prev;
    struct Node* next;
} Node;

typedef struct DList {
    Node* head;
    Node* tail;
} DList;

DList* init_list();

Node* create_node(ElemType data);

Node* create_node_with_pointer(ElemType data, Node* prev, Node* next);

void add_head(DList* list, ElemType data);

void add_tail(DList* list, ElemType data);

void add_node(DList* list, ElemType data, int index);

void del_head(DList* list);

void del_tail(DList* list);

void del_node(DList* list, int index);

ElemType get_head(DList* list);

ElemType get_tail(DList* list);

ElemType get_node(DList* list, int index);

int get_length(DList* list);

void print_DList_from_head(DList* list);

void print_DList_from_tail(DList* list);

void clear_DList(DList* list);
